<!--头部公共部分-->
{include file="common/header" /}
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a>首页</a>
        <a>系统</a>
        <a>
          <cite>系统配置</cite></a>
      </span>
    <a class="layui-btn layui-btn-xs layui-btn-small" style="float:right;margin-top: 10px;"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh"></i> </a>
</div>

<div class="layui-tab layui-tab-card" lay-filter="filter">
    <div class="layui-tab-content" >
        <div class="layui-tab-item layui-show">
            <div id="jiben" class="x-body" class="clear:both;">
                <div style="padding:15px;">
                    <form class="layui-form layui-form-pane">
                        {foreach name="group" id="v"}
                        {if $v['type'] == 132}
                        <div class="layui-form-item">
                            <label class="layui-form-label">{$v.title}</label>
                            <div class="layui-input-block">
                                <input type="text" name="{$v.name}" value="{$v.value}" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        {elseif $v['type'] == 133/}
                        <!--单选-->
                        {elseif $v['type'] == 135/}
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">{$v.name}</label>
                            <div class="layui-input-block">
                                <textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea>
                            </div>
                        </div>
                        {elseif $v['type'] == 136/}
                        <!--上传-->
                        {/if}
                        {/foreach}
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input class="layui-btn" lay-submit lay-filter="form" value="立即提交" readonly>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!--底部公共部分-->
{include file="common/footer" /}
<script>
    layui.use(['element', 'table','jquery','form','layer'], function(){
        let $ = layui.jquery
                ,element = layui.element
                ,layer = layui.layer
                ,form = layui.form;

        //监听提交
        form.on('submit(form)', function (data) {
            let field = data.field;
            field.type = $('select[name=type]').val();
            field.group = $('select[name=group]').val();
            let isLoad;
            $.ajax({
                url: '{:url("System/system")}',
                method: "post",
                data: field,
                beforeSend: function () {
                    isLoad = layer.load(0, {
                        shade: false
                    }); //0代表加载的风格，支持0-2
                },
                success: function (result) {
                    layer.msg(result.msg);
                    if (result.code === 1) {
                        setTimeout(function () {
                            location.reload();
                        }, 2000);
                    }
                },
                complete: function () {
                    layer.close(isLoad)
                },
                error: function (error) {
                    console.log(error)
                }
            });
            return false;
        });
    });
</script>